/*
 * -------------------------------------------------------------------------------
 * @FilePath     : app_init.h
 * @Description  : application
 * Copyright (c) 2023 by NanoIC, All Rights Reserved. 
 * @Date         : 2023-11-10 00:58:17
 * @LastEditTime : 2023-11-10 18:20:49
 * @Author       : LvH
 * -------------------------------------------------------------------------------
 */
/*-------------------------------------------------------------------------------
* file:     app_init.h
* brief:    application
* copyright Copyright (C) 2020-2022 @ NanoIC
* Date:     2022-08-15
* Version:  V1.00
* Author:   JMH
*-------------------------------------------------------------------------------*/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __APP_INIT_H__
#define __APP_INIT_H__

/* Includes ------------------------------------------------------------------*/
#include "common.h"
#include <sys_clk.h>
#include "pin.h"
#include <drv/iwdt.h>
/*----------------------------------------------------------------------------*/
#include "app_cfg.h"
#include "app_lowpower.h"
#include "app_uart.h"
#include "app_upgrade.h"
#include "app_key.h"
#include "app_timer.h"
#include "app_spi.h"
#include "one_wire_bus_app.h"
#include "board_config.h"
#include "app_iic.h"
#include "app_touchpad.h"
#include "app_factory.h"
#include "app_gsensor.h"
#include "app_sleeptimer.h"
#include  "tl_log.h"


/* Private macro-----------------------------------------------------------*/
#define HARDWARE_IO          PA111

#define TP_SCAN_TIMER_N      4000
#define Gsensor_SCAN_TIMER_N 5000

extern volatile uint8_t global_dvt_or_evt_choose;

extern volatile bool global_soc_init_succes_flag;


extern volatile uint8_t one_wire_tra_tmp_buf[SEND_LONG_ONE_WIRE_BLOCK_QUEUE_LENGTH];
extern uint8_t device_info_send_flag;
extern uint8_t device_version_info_send_flag;
extern uint8_t device_extend_info_send_flag;
extern uint8_t accel_info_send_flag;
extern uint32_t uart_100us_timer_tick;
extern uint8_t syn_flag,device_flag;
extern uint32_t  syn_100us_timer_tick;
extern uint32_t handshake_ack_tick;
extern uint8_t handshake;

//extern uint32_t send_ack_tick;
extern bool send_ack_flag;
extern uint32_t test_tick;
extern uint32_t sleep_tick;
//---------------------------------------------------------------------------//
/**
 * @brief app初始化
 * 
 * @param debug_io_en 
 */
void app_init(void);

/**
 * @brief 关闭时钟
 */
void app_power_saving_clk_disable(void);

/**
 * @brief 设置唤醒中断
 * 
 */
void app_set_wakeup_irq(void);

/**
 * @brief 清理中断
 * 
 */
void app_clear_wakeup_irq(void);

/**
 * @brief 看门狗清理
 * 
 */
void app_iwt_clr(void);

/**
 * @brief 初始化计时时基
 * 
 */
void app_iic_init_timer_tick_0_1ms_handler(void);

/**
 * @brief  需要上电后延迟初始化的部分
 * 
 */
void app_delay_init(void);

/**
 * @brief 开机读取硬件版本
 * 
 */
uint8_t app_hardware_version_read(void);

/**
 * @brief 硬件io休眠函数
 * 
 * @param on false 休眠
 */
void app_hardware_ver_lowpower_io_set(bool on);

#endif
